<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改渠道信息')" />
    <th:block th:include="include :: select2-css" />

</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-channel-edit" th:object="${channelInfo}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">渠道编号：</label>
                <div class="col-sm-8">
                    <input name="channelCode" th:field="*{channelCode}" readonly="true" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">渠道名称：</label>
                <div class="col-sm-8">
                    <input name="channelName" th:field="*{channelName}" readonly="true"  class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">应用名称：</label>
                <div class="col-sm-8">
                    <select name="appType"  class="form-control"  th:field="*{appType}">
                        <option  th:each="item:${appTypeList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">渠道类型：</label>
                <div class="col-sm-8">
                    <select name="channelType"  class="form-control"  th:field="*{channelType}">
                        <option  th:each="item:${channelTypeList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">渠道计价类型：</label>
                <div class="col-sm-8">
                    <input id="chargeTypeStr" readonly="true"  class="form-control" type="text" required>
                    <input name="chargeType" id="chargeType" th:field="*{chargeType}"  class="form-control" type="hidden">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">流量类型：</label>
                <div class="col-sm-8">
                    <select name="flowRateType"  class="form-control"  th:field="*{flowRateType}">
                        <option  th:each="item:${flowRateTypeList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>


<!--            <div class="form-group" id="channelRate">-->
<!--                <label class="col-sm-3 control-label is-required">渠道比率：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="channelRate" th:field="*{channelRate}" class="form-control" type="text" required>-->
<!--                    <span style="color: red">渠道统计时，按照该值进行扣量（例如：0.9。扣量10%）</span>-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">是否联登渠道：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select name="unionFlag" th:field="*{unionFlag}">-->
<!--                        <option value="0">非联登</option>-->
<!--                        <option value="1">联登</option>-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">渠道价格：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="chargeAmount" th:field="*{chargeAmount}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">落地页类型：</label>
                <div class="col-sm-8">
                    <select name="pageType"  class="form-control">
                        <option  th:each="item:${typeList}" th:text="${item.name}" th:selected="${item.flag}" th:value="${item.type}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">不包括的产品：</label>
                <div class="col-sm-8">
                    <label class="check-box" th:each="item:${productList}">
                        <input type="checkbox" name="notIncludeProduct" th:value="${item.value}" th:checked="${item.flag}" th:text="${item.name}"></label>
                    </label>
                    <span style="color: red">该渠道不展示的产品信息</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">不包括的来源：</label>
                <div class="col-sm-8">
                    <label class="check-box" th:each="item:${sourceList}">
                        <input type="checkbox" name="notIncludeSource" th:value="${item.value}" th:checked="${item.flag}" th:text="${item.name}"></label>
                    </label>
                    <span style="color: red">该来源的请求不展示</span>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "extend/channel";
        $("#form-channel-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-channel-edit').serialize());
            }
        }

        function chargeTypeFun() {
            var typeValue =$('#chargeType').val();
            if (typeValue == 2){
                // $('#channelRate').show()
                $('#chargeTypeStr').val("注册计价")
            }else if (typeValue == 1){
                // $('#channelRate').hide()
                $('#chargeTypeStr').val("UV计价")
            }else if (typeValue == 3){
                // $('#channelRate').hide()
                $('#chargeTypeStr').val("联登计价")
            }
        }

        chargeTypeFun();

    </script>
</body>
</html>